﻿@{
    ViewData["Title"] = "Error";
    Layout = ViewData.ContainsKey("InAjax") ? null : "_Layout";
    ViewData["UseLightTheme"] = true;
    var code = (System.Net.HttpStatusCode)ViewBag.StatusCode;
    var codename = System.Text.RegularExpressions.Regex.Replace(code.ToString(), "([a-z])([A-Z])", "$1 $2");
}

<div class="container mt-5">
    <div class="row">
        <div class="col-md-12">
            <div class="error-template">
                <h1>
                    @((int)code) @codename
                </h1>
                <div class="error-details">
                    Sorry, an error has occured: @(codename).
                </div>
                <div class="error-details">
                    Please contact a staff member for assistance.
                    <br />
                    <code>@ViewBag.RequestId</code>
                </div>
                @if (code == System.Net.HttpStatusCode.InternalServerError
                    && User.IsInRole("Administrator")
                    && Context.Items.TryGetValue("Microsoft.AspNetCore.Diagnostics.UnhandledException", out var _ex1)
                    && _ex1 is Exception ex)
                {
                <div class="error-details mt-4" style="text-align: left;">
                    <pre style="color: #555555; white-space: pre-wrap; word-wrap: break-word;">@ex.ToString()</pre>
                </div>
                }
            </div>
        </div>
    </div>
</div>
